
#ifndef QRENDERQUATERNION_H
#define QRENDERQUATERNION_H

#include <string>
#include <cmath>

#include "glew.h"

#define EPSILON         1e-5
#define PI              3.14259265359

class QRenderColor
{
public:
    unsigned char r;
    unsigned char g;
    unsigned char b;
    unsigned char a;
    QRenderColor();
    QRenderColor(unsigned char i);
    QRenderColor(unsigned char r, unsigned char g, unsigned char b);
    QRenderColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
    ~QRenderColor();
};

class QRenderVector3
{
public:
    QRenderVector3();
    QRenderVector3(const QRenderVector3 &v);
    QRenderVector3(float x, float y, float z);
    ~QRenderVector3();
    float x;
    float y;
    float z;
    
    friend QRenderVector3 operator +(const QRenderVector3 &v, const float &f);
    friend QRenderVector3 operator -(const QRenderVector3 &v, const float &f);
    friend QRenderVector3 operator *(const QRenderVector3 &v, const float &f);
    
    friend QRenderVector3 operator +(const QRenderVector3 &v1, const QRenderVector3 &v2);
    friend QRenderVector3 operator -(const QRenderVector3 &v1, const QRenderVector3 &v2);
    friend QRenderVector3 operator *(const QRenderVector3 &v1, const QRenderVector3 &v2);
    
    static float dot(const QRenderVector3 &v1, const QRenderVector3 &v2);
    static QRenderVector3 cross(const QRenderVector3 &v1, const QRenderVector3 &v2);
    static float length(const QRenderVector3 &v);
    static QRenderVector3 normalize(const QRenderVector3 &v);
private:
    
};

class QRenderVertex
{
public:
    QRenderVector3 position;
    QRenderColor color;
    QRenderVector3 normal;
    unsigned char padding[4];
    QRenderVertex();
    QRenderVertex(const QRenderVector3 &position, const QRenderColor &color, const QRenderVector3 &normal);
    ~QRenderVertex();
};

class QRenderVector4
{
public:
    QRenderVector4();
    QRenderVector4(float x, float y, float z, float w);
    ~QRenderVector4();
    float x;
    float y;
    float z;
    float w;
    
    friend QRenderVector4 operator *(const QRenderVector4 &t1, const QRenderVector4 &t2);
    friend QRenderVector3 operator *(const QRenderVector4 &t, const QRenderVector3 &v);
    
    static void getAngleAxis(const QRenderVector4 &q, QRenderVector3 &v, float *angle);
    static QRenderVector4 fromAngleAxis(float angle, const QRenderVector3 &axis);
    static QRenderVector4 normalize(const QRenderVector4 &q);
    static QRenderVector4 inverse(const QRenderVector4 &q);
private:

};

#endif  // QRENDERSTRUCTURE_H